package cn.jinjimi.app.custom.utils;

import cn.jinjimi.app.custom.entity.Custom;

import java.util.Comparator;

/**
 * Created by sun on 2015/5/22.
 */
public class LetterUtil {

    public static class ComparatorTop implements Comparator<Custom> {
        @Override
        public int compare(Custom lhs, Custom rhs) {
            if (lhs.top > rhs.top)
                return -1;

            if (lhs.top == rhs.top) {
                if (lhs.topTime > rhs.topTime)
                    return -1;
                else
                    return 0;
            }

            if (lhs.top < rhs.top)
                return 1;

            return 0;
        }
    }

    /**
     * 判断一个字符串是不是英文
     *
     * @param charaString
     * @return
     */
    private static boolean isEnglish(String charaString) {
        return charaString.matches("^[a-zA-Z]*");
    }

    /**
     * 判断一个字符串是不是中文
     *
     * @param chineseStr
     * @return
     */
    private static boolean isChineseCharacter(String chineseStr) {
        char[] charArray = chineseStr.toCharArray();
        for (int i = 0; i < charArray.length; i++) {
            if ((charArray[i] >= 0x4e00) && (charArray[i] <= 0x9fbb)) {
                return true;
            }
        }
        return false;
    }
}
